package com.music.biz.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;

import com.music.biz.ShoppingCartBiz;
import com.music.dao.ShoppingCartDao;
import com.music.entity.ShoppingCart;

@Service("shoppingCartBiz")
public class ShoppingCartBizImpl implements ShoppingCartBiz {

	@Autowired
	private ShoppingCartDao shoppingCartDao;
	
	
	public void setShoppingCartDao(ShoppingCartDao shoppingCartDao) {
		this.shoppingCartDao = shoppingCartDao;
	}
	
	@Transactional(propagation=Propagation.REQUIRED)
	public void add(ShoppingCart shoppingCart) {
		shoppingCartDao.add(shoppingCart);

	}



	public List<ShoppingCart> getShoppingCartsByUserId(int id) {
		
		return shoppingCartDao.getShoppingCartsByUserId(id);
	}

	public int getShoppingCarById(int userId, int albumId) {
		
		return shoppingCartDao.getShoppingCarById(userId, albumId);
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void updateSum(int userId, int albumId) {
		shoppingCartDao.updateSum(userId, albumId);
		
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void deleteShoppingCart(int id) {
		shoppingCartDao.deleteShoppingCart(id);
		
	}

	@Override
	public void deleteShoppingCartByuid(int id) {
		shoppingCartDao.deleteShoppingCartByuid(id);
		
	}

	
	
}
